Home > Support > HOWTO List > Tomcat with Plesk

Ditch Plesk's Tomcat?

Plesk is a hosting control panel.  It includes 'Tomcat support'.  That support let's you upload webapps (war files).  And have them appear under "http://yourdomain/webappname".

Before you use the Plesk Tomcat setup, be aware:

Alternative to Using Plesk's Tomcat

As a result of the above 'issues', we do not favor using the Tomcat setup bundled with Plesk.  Instead we prefer using a recent (e.g. Tomcat 5.5.), vanilla setup.

If you skip using Plesk's Tomcat you will, however, need to manually setup webapps.  This is acceptable for some users.  For example if the server admin is the only person uploading webapps.  Or if the server admin is OK with manually setting up webapps initially.  Users can update their war files (via FTP) themselves.

Using a Vanilla Tomcat with Plesk

First: install tomcat.  This is typically done by default on new RimuHosting servers.  If not we can do it for you, just pop in a support ticket.

Next, let us assume we are working on setting up a root webapp for the domain example.com.

Setup the example.com domain in Plesk.  Determine what the Plesk user is for this domain.  Typically this is the last entry added to /etc/passwd.  Typically it is the first part of the domain name.  You can see it in the user column of the directory listing in Plesk's file manager.  In this case let us assume the user name is example.

FYI: In addition to the domain's user name there are a couple of standard Plesk domain names that are used by all Plesk instances: psaserv and psacln.

The following steps will setup a root webapp for the example.com domain:


domain=example.com
user=example
# note this assumes you are running a recent Plesk. else
# the domain will actually be under /home/vhosts
mkdir /var/www/vhosts/$domain/webapps
chown $user:psaserv /var/www/vhosts/$domain/webapps
chmod o-r /var/www/vhosts/$domain/webapps
# upload a webapp (in this case example.war)
# via ftp or via Plesks file manager to that webapps 
# directory
# the file should be owned by $user with a group of psacln.
# In order for tomcat to read it it will be world readable:
chmod o+r /var/www/vhosts/$domain/webapps/example.war

Next add the following host entry to tomcat's server.xml file:


<Host name="example.com" appBase="/var/www/vhosts/example.com/webapps">
<Context path="" docBase="/var/www/vhosts/example.com/webapps/example.war" debug="0"/>
<Alias>www.example.com</Alias>
</Host>

Note: CentOS5 and Apache 2.2.x, just follow the example in /etc/http/conf.d/proxy_ajp.conf and don't use mod_jk2, so ignore the next two paragraphs.

Next add the following to /etc/httpd/conf/workers2.properties


[uri:example.com:80/*]
worker=ajp13:localhost:8009
[uri:www.example.com:80/*]
worker=ajp13:localhost:8009

We thought that adding:


<Location "/">
  JkUriSet worker ajp13:localhost:8009
</Location>

to /var/www/vhosts/cfotodayaz.com/conf/vhost.conf would also work.  However it does not.  Oh well.  The workers2.properties method goes ok.

Update: maybe try running /usr/local/psa/admin/sbin/websrvmng --reconfigure-vhost --vhost=yourdomain.com prior to editing that vhost file and it will work?

Restart tomcat and apache (/etc/init.d/tomcat restart; /etc/init.d/httpd restart).

Now you should be able to access your webapp at:
"http://example.com:8080/" and "http://example.com/"

When you upload a new war file to replace example.war, tomcat should automatically pick up the changes.  i.e. no admin intervention is required to update the webapp, the webapp developer can do that by themselves after it has been setup initially.

For a bit more info about mod_jk2 see http://rimuhosting.com/mod_jk2.jsp

For more info on the RimuHosting Tomcat install see http://rimuhosting.com/tomcat.jsp

Note on Root Webapps

When you have a webapp at the root (i.e. /) context then all content will be served by tomcat.  i.e. you won't also be able to have some content served by apache (e.g. php) for that domain.  The workaround is to put the webapp at a context like /webapp.  Or to have a subdomain (e.g. phpapp.example.com) for the non-Tomcat content.